﻿<div class="contrl">
    <label>省份：</label>
    @Html.DropDownList("province", new SelectList(NMCProvinceBll.GetList(), "ProvinceAJC", "ProvinceName"), new { @class = "select" })
</div>
<div class="contrl">
    <label>城市：</label>
    @Html.DropDownList("city", new SelectList(NMCCityBll.GetList(ViewData["province"] as string), "CityCode", "CityName"), new { @class = "select" })
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#province").change(function () {
            var provinceAJC = $(this).val();
            GetCitySelect(provinceAJC);
        });
    });
    
    function GetCitySelect(provinceAJC) {
        $.ajax({
            type: "GET",
            data: { provinceAJC: provinceAJC },
            url: "@Url.Action("GetJsonCityListByProvinceAJC","Ajax")",
            async: false,
            cache: false
        }).done(function (jsonData) {
            var city = $("#city");
            city.empty();
            for (var i in jsonData) {
                city.append("<option value='" + jsonData[i].CityCode + "'>" + jsonData[i].CityName + "</option>");
            }
        });
    }
</script>